Returns the access mode or the file access number of a file that was opened with the Open statement. The file access number is dependent on the operating system (OSH = Operating System Handle).
Open ステートメントでオープンしたファイルのファイルアクセス番号ないしアクセスモードを返します。ファイルアクセス番号は、オペレーティングシステムに依存します (OSH = Operating System Handle)。
![]() | If you use a 32-Bit operating system, you cannot use the FileAttr-Function to determine the file access number.
32 ビット系オペレーティングシステムを使用している場合、FileAttr 関数でファイルアクセス番号を取得することはできません。 |
See also: Open
次も参照してください:Open
FileAttr (FileNumber As Integer, Attribute As Integer)
FileAttr (FileNumber As Integer, Attribute As Integer)
Integer
整数
FileNumber: The number of the file that was opened with the Open statement.
FileNumber: Open ステートメントでオープンしたファイルの番号。
Attribute: Integer expression that indicates the type of file information that you want to return. The following values are possible:
Attribute: 取得するファイル情報のタイプを指定する整数表式。ここには下記の値を指定できます。
1: The FileAttr-Function indicates the access mode of the file.
1: FileAttr 関数に、該当ファイルのアクセスモードを取得させます。
2: The FileAttr-Function returns the file access number of the operating system.
2: FileAttr 関数に、オペレーティングシステムのファイルアクセス番号を取得させます。
If you specify a parameter attribute with a value of 1, the following return values apply:
属性パラメータに 1 を指定した場合は、下記の戻り値が返されます。
1 - INPUT (file open for input)
1 - INPUT (入力用にファイルをオープン)
2 - OUTPUT (file open for output)
2 - OUTPUT (出力用にファイルをオープン)
4 - RANDOM (file open for random access)
4 - RANDOM (ランダムアクセス用にファイルをオープン)
8 - APPEND (file open for appending)
8 - APPEND (順編成用にファイルをオープン)
32 - BINARY (file open in binary mode).
32 - BINARY (バイナリモードでファイルをオープン)
Sub ExampleFileAttr
Sub ExampleFileAttr
Dim iNumber As Integer
Dim iNumber As Integer
Dim sLine As String
Dim sLine As String
Dim aFile As String
Dim aFile As String
aFile = "c:\data.txt"
aFile = "c:\data.txt"
iNumber = Freefile
iNumber = Freefile
Open aFile For Output As #iNumber
Open aFile For Output As #iNumber
Print #iNumber, "This is a line of text"
Print #iNumber, "This is a line of text"
MsgBox FileAttr(#iNumber, 1 ),0,"Access mode"
MsgBox FileAttr(#iNumber, 1 ),0,"Access mode"
MsgBox FileAttr(#iNumber, 2 ),0,"File attribute"
MsgBox FileAttr(#iNumber, 2 ),0,"File attribute"
Close #iNumber
Close #iNumber
End Sub
End Sub